/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.tom.social.dal.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Tom
 */
@Entity
@Table(name = "Analysis")
@NamedQueries({@NamedQuery(name = "Analysis.findAll", query = "SELECT a FROM Analysis a"),
	@NamedQuery(name = "Analysis.findByType", query = "SELECT a FROM Analysis a WHERE a.type = :type")})
public class Analysis implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Basic(optional = false)
	@Column(name = "id")
	private Integer id;
	@Basic(optional = false)
	@Column(name = "created")
	@Temporal(TemporalType.TIMESTAMP)
	private Date created;
	@Basic(optional = false)
	@Column(name = "type")
	private int type;
	@JoinTable(name = "Site_Analysis", joinColumns = {@JoinColumn(name = "analysis_id", referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "site_id", referencedColumnName = "id")})
	@ManyToMany(fetch = FetchType.LAZY)
	private List<Site> siteList;

	public Analysis() {
	}

	public Analysis(Date created, int type) {
		this.created = created;
		this.type = type;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public List<Site> getSiteList() {
		return siteList;
	}

	public void setSiteList(List<Site> siteList) {
		this.siteList = siteList;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		if(!(object instanceof Analysis)) {
			return false;
		}
		Analysis other = (Analysis) object;
		if((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "pl.tom.social.dal.entity.Analysis[id=" + id + "]";
	}

}
